<form class="registed form_style" style="margin-top:0px;padding:0px" onsubmit="return false;">
	<div style="float: left;position: relative;display: block;width: 98%;height: 45px;padding: 5px;border-bottom:1px solid #e0e0e0">
		&emsp;<strong>Search</strong>&emsp;<input id="cussearch" type="text" />
		&emsp;<input type="button" style="margin: 5px;float: right;" value="New" id="cusnew"  />
		<!--&emsp;<input type="button" style="margin: 5px;float: right;" value="Edit" />-->
	</div>
	<table id="customer_list" style="height:260px">
		<thead>
			<tr style="display:block;position:relative;">
				<th style="width: 200px;">Name</th>
				<th style="width: 200px;">Company</th>
				<th style="width: 100px;">Email</th>
				<th style="width: 150px;">Address</th>
				<th style="width: 150px;">Contact</th>
			</tr>
		</thead>
		<tbody style="height: 210px;overflow: auto;display: block;width:inherit;">
		</tbody>
	</table>
</form>
<script>
$('#cussearch').keyup(function () {
	var term = $(this).val();
	var target = $($(this).attr('target'));
	delay(function(){
    	$.post('?module=login&action=search', {
    		term: term,
    		type: 1
    	}, function (data) {
    		$('#customer_list tbody').hide().html(data).fadeIn('slow');
    		$('#customer_list tbody tr').dblclick(function () {
				if(target.length > 0 ){
        			target.val($(this).find('td:nth-child(2)').text());
        			target.attr('aid', $(this).attr('aid')).attr('address', $(this).find('td:nth-child(4)').text());
        			$('#form_search_customer').dialog('close');
				}
    		});
    	});
	}, 500);
});
$('#cusnew').click(function(){
	$.post('?module=register&action=customer&ajax=1', function(data){
		$('#form_new_customer').html(data).dialog('open');
	});
});
$('#form_new_customer').dialog({
	autoOpen: false,
	height: 380,
	width: 600,
	resizable: false,
	modal: true,
	hide: {
		effect: "fade",
		duration: 400
	}
});
</script>
